package com.schedule.service.impl;

import com.github.pagehelper.PageHelper;
import com.schedule.Util.PagedGridResult;
import com.schedule.mapper.PlayCompetitionMapper;
import com.schedule.pojo.CompetitionGradeInfo;
import com.schedule.pojo.Player1;
import com.schedule.service.IPlayCompetitionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PlayCompetitionServiceImpl implements IPlayCompetitionService {
    @Autowired
    private PlayCompetitionMapper playCompetitionMapper;

    /**
     * 分页查询所有裁判
     * page: 第几页
     * pageSize: 每页显示条数
     */
    @Override
    public PagedGridResult findAll(Integer page, Integer pageSize) {
        PageHelper.startPage(page, pageSize);
        List<Player1> players = playCompetitionMapper.findAll();
        PagedGridResult gridResult = PagedGridResult.setterPagedGrid(players, page);
        return gridResult;
    }

    /**
     * 分页查询根据比赛查找选手及分数
     * page: 第几页
     * pageSize: 每页显示条数
     */
    public PagedGridResult findAllByCompetition(Integer page, Integer pageSize){
        PageHelper.startPage(page, pageSize);
        List<CompetitionGradeInfo> players = playCompetitionMapper.findAllByCompetition();
        PagedGridResult gridResult = PagedGridResult.setterPagedGrid(players, page);
        return gridResult;
    }

    /**
     * 根据选手的ID查找该选手参加的比赛及分数
     * @return
     */
    @Override
    public List<Player1> findCompetitionByPid(Integer pid) {
        return playCompetitionMapper.findCompetitionByPid(pid);
    }



}
